// Name: Jon Wesel
// Course: SSW 567
// Assignment: 1

public class Triangle {
	
	double THRESHOLD =.01;
	double a,b,c;
	String type;
	boolean right;
	
	public Triangle(double x, double y, double z){
		a = x;
		b = y;
		c = z;
		type = checkType();
		right = checkRight();
	}
	
	private boolean checkRight() {
		if(!isValid() || checkType() == "equilateral")
			return false;
		
		if(Math.abs((a*a + b*b) - c*c) - THRESHOLD < 0 ||
		   Math.abs((b*b + c*c) - a*a) - THRESHOLD < 0||
		   Math.abs((a*a + c*c) - b*b) - THRESHOLD < 0)
				   return true;
	
		return false;
	}

	public String getType(){ return type; }
	
	public boolean isRight(){ return right; }
	
	private String checkType(){
		if(!isValid())
			return "Invalid";
		if(isEquilateral())
			return "Equilateral";
		if(isScalene())
			return "Scalene";
		
		return "Isosceles";
	}

	private boolean isScalene() {
		return a != b &&
			   a != c &&
			   b != c;
	}

	private boolean isEquilateral() {
		return a == b && 
			   b == c;
	}

	private boolean isValid() {
		if (a <= 0 || b <= 0 || c <= 0)
			return false;
		
		if (a >= b && a >= c)
			return a < b + c;
		
		if (b >= a && b >= c)
			return b < a + c;
		
		return c < a + b;
	}

	public String getDescription() {
		if(!isValid())
			return "Invalid Triangle";
		
		String desc = "";
		if(isRight())
			desc = "Right ";
		desc += getType() + " Triangle";
	
		return desc;
	}
}
